// console.log(requirejs.s.contexts._.config,'requirejs')
require.config({
    urlArgs: "v=" + requirejs.s.contexts._.config.config.site.version,
    packages: [{
        name: 'moment',
        location: '../../assets/libs/moment',
        main: 'moment'
    }],
    //在打包压缩时将会把include中的模块合并到主文件中
    include: ['css', 'layer', 'toastr', 'fast', 'backend', 'backend-init', 'table', 'form', 'dragsort', 'drag', 'drop', 'addtabs', 'selectpage','bootstrap-tagsinput'],
    paths: {
        // 以下的包从bower的libs目录加载
        'jquery': '../../assets/libs/jquery/dist/jquery.min',
        'layer': '../../assets/libs/layer/layer',
        'vue': '../../assets/libs/vue/3/vue',
        'ELEMENT':"../../assets/libs/element-plus/index.full",
        'ELEMENTICON':"../../assets/libs/element-plus/icon",
        'common':"../../assets/libs/common/common",
        "leyuivue":"../../assets/libs/layuivue/index"
    },
    // shim依赖配置
    shim: {
        'vue':{
            exports:"Vue"
        },
        'ELEMENT':{
            deps:[
                'vue',
                'css!../../assets/libs/element-plus/index.css'
            ]
        },
        "ELEMENTICON":{
            deps:[
                'vue',
                'ELEMENT'
            ]
        },
        "common":{
            deps:[
                'vue',
                'ELEMENT',
                'ELEMENTICON',
                'jquery'
            ]
        },
        'layer':{
            deps:[
                'css!../../libs/layer/css/layer.css'
            ]
        },
    },
    baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets', //资源基础路径
    map: {
        '*': {
            'css': '../../assets/libs/require-css/css.min'
        }
    },
    waitSeconds: 60,
    charset: 'utf-8' // 文件编码
});

require(['jquery'], function ($) {
    // console.log( requirejs.s.contexts._.config,'ccccccccccccc')
    //初始配置
    var Config = requirejs.s.contexts._.config.config;
    //将Config渲染到全局
    window.Config = Config;
    // 配置语言包的路径
    var paths = {};
    paths['lang'] = Config.lang_url + '?callback=define&controllername=' + Config.controllername+'&modulename='+Config.modulename + '&lang=' + Config.language + '&v=' + Config.site.version;
    // console.log(paths,Config,'pppppppppppppppppppppppppp')
    // 避免目录冲突
    paths['backend/'] = Config.modulename;
    console.log(paths, 'paths')
    // console.log(Config,'-------------------------------')
    require.config({paths: paths});
    $(function (){
        if(Config.jsname){
            require([Config.jsname], function (Controller) {
                if (Controller.hasOwnProperty(Config.actionname)) {
                    Controller[Config.actionname]();
                } else {
                    if (Controller.hasOwnProperty("_empty")) {
                        Controller._empty();
                    }
                }
            }, function (e) {
                console.error(e);
                // 这里可捕获模块加载的错误
            });
        }
    })
});
